home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group98c.txt
/
000068_icon-group-sender _Tue Nov 3 12:33:05 1998.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
3KB
Return-Path: <icon-group-sender>
Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) with SMTP id MAA19788
for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Tue, 3 Nov 1998 12:33:04 -0700 (MST)
Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
id AA14807; Tue, 3 Nov 1998 12:32:27 -0700
Date: Tue, 3 Nov 1998 09:30:12 -0700
From: swampler@noao.edu (Steve Wampler)
Subject: Re: How to read integers and others
To: icon-group@optima.CS.Arizona.EDU
Message-Id: <swampler-9810031630.AA002220442@orpheus.gemini.edu>
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
- Forwarded message from rpereda@ringer.cs.utsa.edu on Mon, 2 Nov 1998 18:48:09 -0600 (CST) -
>
> # Please RTFM, "String Scanning and Pattern Matching" chapter
> # in the Icon book, or scanning in one of the many online reference
> # documents.
> # Also, start by reading http://www.cs.arizona.edu/icon/intro.htm
>
> procedure main()
> while line := read() ? {
> tab(upto(&letters))
> word := tab(many(&letters))
>
> tab(upto(&digits))
> num := integer(tab(many(&digits)))
>
> write("number: ", num, " word: ", word)
> }
> end
>
> -ray
As I understand Robert's question, the above program will not work. He
appears to want to scan in 32-bit integers, not ascii strings that 'look
like' integers. That is, each word in his list is followed by the
4 bytes for the 32-bit integer (2's-complement, I assume).
Robert, if I'm correct in how I'm interpreting your question, this
isn't that easy to do directly in Icon. You'd have to read in the
4 bytes with reads() and the figure out to reconstruct the integer
from that 4-byte string of ascii. (This isn't too hard if you
are dealing with only non-negative values [the ord() function can
help] but handling the 2-s complement for negative values strikes me
as ugly.)
Somebody has probably done this already.
Incidently, you'd be better off if you used printf in your C retrieve
program to output the 32-bit integer as it's ascii equivalent, in which
case you could use a technique such as the one Ray suggests above.
> On 2 Nov 1998, Robert Valliant wrote:
>
> > I have an information retrieval program written in "c" that I would
> > like to convert to a web application.
> >
> > The indexing portion of the application generates an inverted file of
> > the format:
> >
> > word 32-bit integer
> > word 32-bit integer
> > .
> > .
> > .
> > word 32-bit integer
> >
> > Can anyone tell me the best way to read these things, using icon? Or
> > am I wasting my time in trying?
--
Steve Wampler - swampler@gemini.edu [Gemini 8m Telescopes Project (under AURA)]
The gods that smiled at your birth are now laughing openly. (Fortune Cookie)